package thread2;

public class Passenger implements Runnable {
	private String name;

	public Passenger(String name) {
		this.name = name;
	}

	@Override
	public void run() {
		System.out.println(name + "抵达了车站");
		for (int i = 1; i <= 20; i++) {
			System.out.println(name + " 坐火车跑了" + i * 100 + "公里");
		}
		System.out.println(name + "抵达了上海");
	}

	public static void main(String[] args) {
		Passenger p1 = new Passenger("孙成宇");
		Thread t1 = new Thread(p1);
		t1.start();
		Thread t2 = new Thread(new Passenger("林心如"));
		t2.start();
		try {
			t1.join();
			t2.join();
		} catch (InterruptedException e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		}
		System.out.println("火车进站了");
	}
}
